{extend name="index_layout"/}
{block name="main"}
<div class="layui-card">
    <div class="layui-card-header"></div>
    <div class="layui-card-body">
        <div class="layui-form">
            <table class="layui-hide" id="currentTable" lay-filter="currentTable"
                   data-auth-add="{:$auth->check('apply_team/add')}"
                   data-auth-edit="{:$auth->check('apply_team/edit')}"
                   data-auth-delete="{:$auth->check('apply_team/del')}"
                   data-auth-recyclebin="{:$auth->check('apply_team/recyclebin')}"
            ></table>
        </div>
        <input type="hidden" id="adminId" value="{$adminId}">

    </div>
</div>

<script type="text/html" id="barTool">
    {{# if(d.status==0){ }}
    <a data-open='{:url("edit")}?id={{ d.id }}'
       class="layui-btn layui-btn-xs {:$auth->check('apply_team/edit')?'':'layui-hide'}" title="审核">审核</a>
    {{#  } }}

    <a href='{:url("del")}?id={{ d.id }}'
       class="layui-btn layui-btn-danger layui-btn-xs layui-tr-del {:$auth->check('apply_team/del')?'':'layui-hide'}"><i
            class='iconfont icon-trash_fill'>
    </i></a></script>

{/block}
{block name="script"}
<script type="text/javascript">
    layui.use('yznTable', function () {
        var table = layui.yznTable;

        var init = {
            table_elem: '#currentTable',
            table_render_id: 'currentTable',
            add_url: '{:url("add")}',
            edit_url: '{:url("edit")}',
            delete_url: '{:url("del")}',
            modify_url: "{:url('multi')}",
            recyclebin_url: "{:url('recyclebin')}",
        };


        var cols =  [
            {type: 'checkbox', fixed: 'left'},
            {field: 'id', title: 'id', minWidth: 80},
            {field: 'admin.team_name', title: '团队名称', minWidth: 80, searchOp: 'LIKE', minWidth: 110},
            {field: 'staff.username', title: '姓名', minWidth: 80, searchOp: 'LIKE', minWidth: 110},
            {field: 'add_reason', title: '加入原因', minWidth: 80, searchOp: 'LIKE', minWidth: 110},
            {
                field: 'status',
                align: 'center',
                title: '状态',
                templet: yznTable.formatter.label,
                selectList: {0: '待审核', 1: '通过', 2: "拒绝"}
            },
            {field: 'no_reason', title: '拒绝原因', minWidth: 80, searchOp: 'LIKE', minWidth: 110},
            {
                field: 'create_time',
                title: '创建时间',
                minWidth: 80,
                width: 180,
                search: 'range',
                templet: yznTable.formatter.datetime
            },
            {
                field: 'update_time',
                title: '更新时间',
                minWidth: 80,
                width: 180,
                search: 'range',
                templet: yznTable.formatter.datetime
            },
            { fixed: 'right', align: 'center', width: 140, title: '操作', toolbar: '#barTool' }

        ]

        //
        // var adminId = $('#adminId').val();
        // if (adminId == 1) {
        //     cols.splice(2, 0, {field: 'admin.username', title: '团队', searchOp: 'like'});
        // }



        table.render({
            init: init,
            toolbar: ['refresh', 'delete'],
            url: '{:url("index")}',
            cols: [
                cols
            ],
            page: {}
        });

        yznTable.bindevent();
    });
</script>
{/block}